package root.loan;

import exceptions.HasAlreadyDoneException;
import exceptions.LoanHasAlreadyBeenApprovedException;
import exceptions.PermissionDeniedException;

/**
 * Status de item que foi aceito para emprestimo.
 */
public class Accepted extends State{

	private final String descricao = "Andamento";
	
	@Override
	public String getDescricao() {
		return descricao;
	}
	
	@Override
	public void aproveBorrow(Borrow borrow) throws LoanHasAlreadyBeenApprovedException ,PermissionDeniedException{
		throw new LoanHasAlreadyBeenApprovedException("Empréstimo já aprovado");
	}
	@Override
	public void cancel(Borrow borrow) throws HasAlreadyDoneException ,PermissionDeniedException{
		mudaEstado(borrow,new Canceled());
	}
	@Override
	public void complete(Borrow borrow) throws HasAlreadyDoneException ,PermissionDeniedException{
		throw new PermissionDeniedException("Item não retornado");
	}
	@Override
	public void requestDevolution(Borrow borrow) throws HasAlreadyDoneException ,PermissionDeniedException{
		mudaEstado(borrow,new AcceptedRequested());
	}
	@Override
	public void returnItem(Borrow borrow) throws HasAlreadyDoneException ,PermissionDeniedException{
		mudaEstado(borrow,new AcceptedReturned());
	}
}
